# !/usr/bin/env python
# -*- coding: UTF-8 -*-
# author: xiazhiquan
# date: Jul 23, 2011

from pymongo import Connection

dbname = 'mms'
host = 'localhost'
port_mongo = 27017

mongo_conn = Connection(host, port_mongo)
server_info = mongo_conn.server_info()
print '\n===========Server Info:' 
for key in server_info:
    print key, ':', server_info[key]
    
print '\n===========Server Info:' 
database_names = mongo_conn.database_names()
for database_name in database_names:
    if database_name == 'mms':
        print 'database', database_name
        database = mongo_conn[database_name]
        collection_names = database.collection_names()
        for collection_name in collection_names:
            print '\n', collection_name
            collection = database[collection_name]
            print collection.find_one()
            print 'count:', collection.count()
            if collection_name != 'system.indexes':
                database.drop_collection(collection_name)
        

